import request from "@/utils/request";

//商品分类 category的增删改查
// 查
export const getCategory = (params = { size: 100 }) =>
  request.get("/category/", { params });
// 增加/创建
export const addCategory = (data) => request.post("/category/", data);
// 修改局部
export const editCategory = (data) =>
  request.patch(`/category/${data.id}/`, data);
//删除
export const deleteCategory = (data) => request.delete(`/category/${data.id}/`);

// 商品列表页面的方法

// 和商品相关的 增删改查的接口
export const getProduct = (params) => request.get("/product/", { params });
// 获取商品的详情
export const getProductById = (id) => request.get(`/product/${id}/`);
// 添加
export const addProduct = (data) => request.post("/product/", data);
// 修改
export const editProduct = (params) =>
  request.patch("/product/id/", { params });
// 删除
export const deleteProduct = (data) => request.delete(`/product/${data.id}/`);
// 只获取商品的id 支持分页
export const getProductIds = (params) =>
  request.get("/product/id/", { params });

// 根据 只包含商品id的数组 批量获取商品详情
// 传递数据的形式：[id1,id2,id3,id4,id5]   传入商品的id 根据id查找对应的
//------
export const getProductByGroup = (data) =>
  request.post("/product/group/", data);

// 上传图片
export const uploadProductImage = (data) =>
  request.post("/product-image/", data);
export const deleteProductImage = (data) =>
  request.delete(`/product-image/${data.id}/`, data);
